home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 22 / CU Amiga Magazine's Super CD-ROM 22 (1998)(EMAP Images)(GB)[!][issue 1998-05].iso / PowerPC / System / PPCReleaseDEV / include / powerup / ppclib / tasks.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-21  |  13.2 KB  |  544 lines

  1. #ifndef POWERUP_PPCLIB_TASKS_H
  2. #define POWERUP_PPCLIB_TASKS_H
  3.  
  4. /**************************************************
  5.  *
  6.  *
  7.  *              PPCCreateTask() Tags
  8.  *
  9.  *
  10.  **************************************************/
  11.  
  12. #define    PPCTASKTAG_DUMMY    (TAG_USER + 0x20000)
  13.  
  14. /* Program Counter Start of the Task */
  15. #define    PPCTASKTAG_ELFOBJECT    (PPCTASKTAG_DUMMY + 0x1)
  16.  
  17. /* Name of the new Task. */
  18. #define    PPCTASKTAG_NAME        (PPCTASKTAG_DUMMY + 0x2)
  19.  
  20. /* First Argument..gpr3 */
  21. #define    PPCTASKTAG_ARG1        (PPCTASKTAG_DUMMY + 0x3)
  22.  
  23. /* First Argument..gpr4 */
  24. #define    PPCTASKTAG_ARG2        (PPCTASKTAG_DUMMY + 0x4)
  25.  
  26. /* First Argument..gpr5 */
  27. #define    PPCTASKTAG_ARG3        (PPCTASKTAG_DUMMY + 0x5)
  28.  
  29. /* First Argument..gpr6 */
  30. #define    PPCTASKTAG_ARG4        (PPCTASKTAG_DUMMY + 0x6)
  31.  
  32. /* First Argument..gpr7 */
  33. #define    PPCTASKTAG_ARG5        (PPCTASKTAG_DUMMY + 0x7)
  34.  
  35. /* First Argument..gpr8 */
  36. #define    PPCTASKTAG_ARG6        (PPCTASKTAG_DUMMY + 0x8)
  37.  
  38. /* First Argument..gpr9 */
  39. #define    PPCTASKTAG_ARG7        (PPCTASKTAG_DUMMY + 0x9)
  40.  
  41. /* First Argument..gpr10 */
  42. #define    PPCTASKTAG_ARG8        (PPCTASKTAG_DUMMY + 0xa)
  43.  
  44. /* Default=TRUE means that the cacheflush is handled automaticly
  45.  * You need cacheflushs when you use OS functions to share data.
  46.  * If you know it better than the stupid cacheflush routine you
  47.  * can handle that yourself and optimize your routines.
  48.  */
  49.  
  50. #define    PPCTASKTAG_CACHEFLUSH    (PPCTASKTAG_DUMMY + 0xb)
  51.  
  52. /* Ptr to an ULONG Errorfield where a better error description
  53.  * can be stored.
  54.  */
  55.  
  56. #define    PPCTASKTAG_ERROR    (PPCTASKTAG_DUMMY + 0xc)
  57.  
  58. /* PPC Stacksize...Default 8192
  59.  * Supported by PowerUP's PPCGetTaskAttr() (V45)
  60.  */
  61. #define    PPCTASKTAG_STACKSIZE    (PPCTASKTAG_DUMMY + 0xd)
  62.  
  63. /* Task Priority..Default 0 */
  64. #define    PPCTASKTAG_PRIORITY    (PPCTASKTAG_DUMMY + 0xe)
  65.  
  66. /* Input Handle..Default Open("Nil:")
  67.  * The handle is closed when the PPC task completes
  68.  */
  69. #define    PPCTASKTAG_INPUTHANDLE    (PPCTASKTAG_DUMMY + 0xf)
  70.  
  71. /* Output Handle..Default Open("Nil:")
  72.  * The handle is closed when the PPC task completes
  73.  */
  74. #define    PPCTASKTAG_OUTPUTHANDLE    (PPCTASKTAG_DUMMY + 0x10)
  75.  
  76. /* Error Handle..Default Open("Nil:")
  77.  * The handle is closed when the PPC task completes
  78.  */
  79. #define    PPCTASKTAG_ERRORHANDLE    (PPCTASKTAG_DUMMY + 0x11)
  80.  
  81. /*
  82.  * When you set this Tag the Task is stopped
  83.  * before the first instruction is executed
  84.  * Only useful for debuggers
  85.  */
  86. #define    PPCTASKTAG_STOPTASK    (PPCTASKTAG_DUMMY + 0x12)
  87.  
  88. /* ExceptionHook
  89.  * The M68k Hook is called when a PPC TaskObject gets an
  90.  * exception which can be processor or software(Kernel Msg)
  91.  * related.
  92.  * That`s the way the ppc.library calls the Hook:
  93.  *
  94.  * BOOL CallHookPkt(hook,TaskObject,ExceptionMsg);
  95.  *
  96.  * The Hook Function is NOT allowed to call PPCLibBase
  97.  * functions to avoid deadlocks.
  98.  * And after the Hook function returns the ExceptionMsg
  99.  * contents IS NOT valid anymore.
  100.  * So you should copy the ExceptionMsg contents to a private
  101.  * buffer and then signal your debugger control task about
  102.  * the event.
  103.  * The Hook return BOOL should tell the ppc.library if all
  104.  * worked fine.
  105.  */
  106.  
  107. #define    PPCTASKTAG_EXCEPTIONHOOK    (PPCTASKTAG_DUMMY + 0x13)
  108.  
  109.  
  110. /* If you want that the PPCTask gets a MsgPort you can tell
  111.  * PPCCreateTask by a TRUE that you want one.
  112.  * I made this optional because it may cause an initial speed
  113.  * loss if you only need a ppc task for a quick run job where
  114.  * the init latency may be a serious issue.
  115.  * Supported by PowerUP's PPCGetTaskAttr()
  116.  */
  117. #define    PPCTASKTAG_MSGPORT        (PPCTASKTAG_DUMMY + 0x14)
  118.  
  119. /* If you wanna provide the ppc a startup msg. This msg will
  120.  * be replied by the ppc.library after the PPC Task ends so
  121.  * you can use this to know that the PPCTask is gone so a
  122.  * PPCUnloadObject() is save now.
  123.  * Supported by PowerUP's PPCGetTaskAttr()
  124.  */
  125. #define    PPCTASKTAG_STARTUP_MSG        (PPCTASKTAG_DUMMY + 0x15)
  126.  
  127. /* The Data field for the PPCMessage
  128.  * Supported by PowerUP's PPCGetTaskAttr()
  129.  */
  130. #define    PPCTASKTAG_STARTUP_MSGDATA    (PPCTASKTAG_DUMMY + 0x16)
  131. /* The Length field for the PPCMessage
  132.  * Supported by PowerUP's PPCGetTaskAttr()
  133.  */
  134. #define    PPCTASKTAG_STARTUP_MSGLENGTH    (PPCTASKTAG_DUMMY + 0x17)
  135. /* The MsgID field for the PPCMessage
  136.  * Supported by PowerUP's PPCGetTaskAttr()
  137.  */
  138. #define    PPCTASKTAG_STARTUP_MSGID    (PPCTASKTAG_DUMMY + 0x18)
  139. /* The flag to activate the CTRL-C;D;E;F gateway to
  140.  * the PPC Task by PPCSendSignal();
  141.  */
  142. #define    PPCTASKTAG_BREAKSIGNAL        (PPCTASKTAG_DUMMY + 0x19)
  143.  
  144.  
  145.  
  146. /* Run Task Synchron Flag which means that the PPCCreateTask
  147.  * doesn`t return until the task completes and the return
  148.  * value is not the TaskObject but the Task`s return value.
  149.  * To check if the task runned correctly check out the
  150.  * PPCTASKTAG_ERROR fieldptr.
  151.  * With this Tag you can do the same what the old RunTaskObject
  152.  * does which interface is a bit limited(compatibility to the
  153.  * first ppc.library version)
  154.  */
  155.  
  156. #define    PPCTASKTAG_WAITFINISH    (PPCTASKTAG_DUMMY + 0x31)
  157.  
  158. /* 
  159.  * PPCTAGTAG_ERROR types
  160.  */
  161.  
  162. #define    ERROR_OK        0
  163. #define    ERROR_MEMORY        1
  164. #define    ERROR_NOPC        2
  165. #define    ERROR_CREATEMSGINTASK    3
  166. #define    ERROR_INPUTHANDLE    4
  167. #define    ERROR_OUTPUTHANDLE    5
  168. #define    ERROR_ERRORHANDLE    6
  169.  
  170.  
  171.  
  172.  
  173. /**************************************************
  174.  *
  175.  *
  176.  * PPCGetTaskAttrs(), PPCSetTaskAttrs() Tags
  177.  *
  178.  *
  179.  **************************************************/
  180.  
  181. /*
  182.  * V45 adds the ti_Data data Set/Get passing if it`s possible
  183.  */
  184.  
  185.  
  186. #define    PPCTASKINFOTAG_DUMMY        (TAG_USER + 0x21000)
  187. /* (Get) */
  188. #define    PPCTASKINFOTAG_NAME        (PPCTASKINFOTAG_DUMMY + 0x1)
  189. /* (Get/Set) */
  190. #define    PPCTASKINFOTAG_PRIORITY        (PPCTASKINFOTAG_DUMMY + 0x2)
  191. /* (Get/Set) */
  192. #define    PPCTASKINFOTAG_CACHEFLUSH    (PPCTASKINFOTAG_DUMMY + 0x3)
  193. /* (Get) */
  194. #define    PPCTASKINFOTAG_STACKSIZE    (PPCTASKINFOTAG_DUMMY + 0x4)
  195. /* (Get) */
  196. #define    PPCTASKINFOTAG_STATE        (PPCTASKINFOTAG_DUMMY + 0x5)
  197. /* (Get/Set) */
  198. #define    PPCTASKINFOTAG_TASK        (PPCTASKINFOTAG_DUMMY + 0x6)
  199.  
  200. /* This means the HOOK function is called for every Task */
  201. #define    PPCTASKINFOTAG_ALLTASK        (PPCTASKINFOTAG_DUMMY + 0x7)
  202.  
  203. /* Hook function which is called for a task so you can ask special fields
  204.  * you may want to use.
  205.  * Msg Parameter is NULL for now.
  206.  * Object Parameter is the TaskObject
  207.  *
  208.  *    HookFunc(Hook, TaskObject, NULL)
  209.  */
  210. #define    PPCTASKINFOTAG_HOOK        (PPCTASKINFOTAG_DUMMY + 0x8)
  211.  
  212. /* (Get) */
  213. #define    PPCTASKINFOTAG_SIGALLOC        (PPCTASKINFOTAG_DUMMY + 0x9)
  214. /* (Get) */
  215. #define    PPCTASKINFOTAG_SIGWAIT        (PPCTASKINFOTAG_DUMMY + 0xa)
  216. /* (Get) */
  217. #define    PPCTASKINFOTAG_SIGRECVD        (PPCTASKINFOTAG_DUMMY + 0xb)
  218. /* (Get) */
  219. #define    PPCTASKINFOTAG_USEDSTACKSIZE    (PPCTASKINFOTAG_DUMMY + 0xc)
  220. /* (Get/Set) */
  221. #define    PPCTASKINFOTAG_INPUTHANDLE    (PPCTASKINFOTAG_DUMMY + 0xd)
  222. /* (Get/Set) */
  223. #define    PPCTASKINFOTAG_OUTPUTHANDLE    (PPCTASKINFOTAG_DUMMY + 0xe)
  224. /* (Get/Set) */
  225. #define    PPCTASKINFOTAG_ERRORHANDLE    (PPCTASKINFOTAG_DUMMY + 0xf)
  226.  
  227. /* Return the ElfObject of a Task
  228.  * (Get)
  229.  * (V45)
  230.  */
  231.  
  232. #define    PPCTASKINFOTAG_ELFOBJECT    (PPCTASKINFOTAG_DUMMY + 0x10)
  233.  
  234. /* See equal PPCTASKTAG_EXCEPTIONHOOK
  235.  * (V45)
  236.  * (Set)
  237.  */
  238.  
  239. #define    PPCTASKINFOTAG_EXCEPTIONHOOK        (PPCTASKINFOTAG_DUMMY + 0x11)
  240.  
  241. /* Tell the task to stop at the first instruction.
  242.  * Only allowed to be used when you get a TaskHookMsg
  243.  * with the MethodID PPCTASKHOOKMETHOD_CREATE.
  244.  * It must not be called while a PPC Task runs.
  245.  * (V45)
  246.  * (Set)
  247.  */
  248. #define    PPCTASKINFOTAG_STOPTASK            (PPCTASKINFOTAG_DUMMY + 0x12)
  249.  
  250.  
  251. /* See equal PPCTASKTAG_MSGPORT
  252.  * (V45)
  253.  */
  254. #define    PPCTASKINFOTAG_MSGPORT            (PPCTASKINFOTAG_DUMMY + 0x13)
  255.  
  256. /* See equal PPCTASKTAG_STARTUP_MSG
  257.  * (V45)
  258.  */
  259. #define    PPCTASKINFOTAG_STARTUP_MSG        (PPCTASKINFOTAG_DUMMY + 0x14)
  260.  
  261. /* See equal PPCTASKTAG_STARTUP_MSGDATA
  262.  * (V45)
  263.  */
  264. #define    PPCTASKINFOTAG_STARTUP_MSGDATA        (PPCTASKINFOTAG_DUMMY + 0x15)
  265.  
  266. /* See equal PPCTASKTAG_STARTUP_MSGLENGTH
  267.  * (V45)
  268.  */
  269. #define    PPCTASKINFOTAG_STARTUP_MSGLENGTH    (PPCTASKINFOTAG_DUMMY + 0x16)
  270.  
  271. /* See equal PPCTASKTAG_STARTUP_MSGID
  272.  * (V45)
  273.  */
  274. #define    PPCTASKINFOTAG_STARTUP_MSGID        (PPCTASKINFOTAG_DUMMY + 0x17)
  275.  
  276.  
  277. /*
  278.  * All Register Tags only accept Ptrs at ti_Data so I don`t have to
  279.  * change the API when there`s a 64Bit PPC some time.
  280.  */
  281.  
  282. /* SRR0=PC
  283.  * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR
  284.  * (Get/Set)
  285.  */
  286. #define    PPCTASKINFOTAG_PC        (PPCTASKINFOTAG_DUMMY + 0x20)
  287.  
  288. /* SRR1=MSR
  289.  * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR
  290.  * (Get/Set)
  291.  */
  292. #define    PPCTASKINFOTAG_MSR        (PPCTASKINFOTAG_DUMMY + 0x21)
  293.  
  294. /* 32bit value in function Result
  295.  * Get/Set through ti_Data
  296.  * (Get/Set)
  297.  */
  298. #define    PPCTASKINFOTAG_CR        (PPCTASKINFOTAG_DUMMY + 0x22)
  299.  
  300. /* 32bit value in function Result
  301.  * Get/Set through ti_Data
  302.  * (Get/Set)
  303.  */
  304. #define    PPCTASKINFOTAG_XER        (PPCTASKINFOTAG_DUMMY + 0x23)
  305.  
  306. /* Result by PPCTASKINFOTAG_VALUEPTR
  307.  * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR
  308.  * (Get/Set)
  309.  */
  310. #define    PPCTASKINFOTAG_LR        (PPCTASKINFOTAG_DUMMY + 0x24)
  311.  
  312. /* Result by PPCTASKINFOTAG_VALUEPTR
  313.  * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR
  314.  * (Get/Set)
  315.  */
  316. #define    PPCTASKINFOTAG_CTR        (PPCTASKINFOTAG_DUMMY + 0x25)
  317.  
  318. /* Result by PPCTASKINFOTAG_VALUEPTR
  319.  * Get/Set through ti_Data or PPCTASKINFOTAG_VALUEPTR
  320.  * (Get/Set)
  321.  */
  322. #define    PPCTASKINFOTAG_FPSCR        (PPCTASKINFOTAG_DUMMY + 0x26)
  323.  
  324. /* ti_Data=Register Number
  325.  * Get/Set through PPCTASKINFOTAG_VALUEPTR
  326.  * (Get/Set)
  327.  */
  328. #define    PPCTASKINFOTAG_GPR        (PPCTASKINFOTAG_DUMMY + 0x30)
  329.  
  330. /* ti_Data=Register Number
  331.  * Get/Set through PPCTASKINFOTAG_VALUEPTR
  332.  * (Get/Set)
  333.  */
  334. #define    PPCTASKINFOTAG_FPR        (PPCTASKINFOTAG_DUMMY + 0x31)
  335.  
  336. /* Address where to read/write the register value from.
  337.  * I use a ptr to be size indepent with the registers
  338.  * (Get/Set)
  339.  */
  340. #define    PPCTASKINFOTAG_VALUEPTR        (PPCTASKINFOTAG_DUMMY + 0x32)
  341.  
  342.  
  343. /* With PPCTASKINFOTAG_WAITFINISHTASK
  344.  * it returns the parent process in which you created
  345.  * a synchron PPC Task. Synchron PPC Task`s are created
  346.  * with the PPCTASKTAG_WAITINFISH,TRUE or outdated a
  347.  * PPCRunObject.
  348.  * The reason for this function is to find the shell
  349.  * task easily and check for a CTRL-C for example.
  350.  * (Get)
  351.  * (V45)
  352.  */
  353. #define    PPCTASKINFOTAG_WAITFINISHTASK    (PPCTASKTAG_DUMMY + 0x33)
  354.  
  355.  
  356.  
  357. /**************************************************
  358.  *
  359.  *
  360.  *           TaskObject ExceptionHook
  361.  *
  362.  *
  363.  **************************************************/
  364.  
  365.  
  366. struct    ExceptionMsg
  367. {
  368.     ULONG            Version;
  369.     ULONG            Type;
  370.     ULONG            GPR[32];
  371.     DOUBLE            FPR[32];
  372.     ULONG            SR[16];
  373.     ULONG            CR;
  374.     DOUBLE            FPSCR;
  375.     ULONG            XER;
  376.     ULONG            LR;
  377.     ULONG            CTR;
  378.     ULONG            PVR;
  379.     ULONG            IBAT0U;
  380.     ULONG            IBAT0L;
  381.     ULONG            IBAT1U;
  382.     ULONG            IBAT1L;
  383.     ULONG            IBAT2U;
  384.     ULONG            IBAT2L;
  385.     ULONG            IBAT3U;
  386.     ULONG            IBAT3L;
  387.  
  388.     ULONG            DBAT0U;
  389.     ULONG            DBAT0L;
  390.     ULONG            DBAT1U;
  391.     ULONG            DBAT1L;
  392.     ULONG            DBAT2U;
  393.     ULONG            DBAT2L;
  394.     ULONG            DBAT3U;
  395.     ULONG            DBAT3L;
  396.  
  397.     ULONG            SDR1;
  398.     ULONG            ASR;
  399.  
  400.     ULONG            DAR;
  401.     ULONG            DSISR;
  402.     ULONG            SRR0;
  403.     ULONG            SRR1;
  404.  
  405.     ULONG            SPRG0;
  406.     ULONG            SPRG1;
  407.     ULONG            SPRG2;
  408.     ULONG            SPRG3;
  409.  
  410.     ULONG            TBL;
  411.     ULONG            TBU;
  412.     ULONG            DEC;
  413.     ULONG            DABR;
  414.  
  415.     /* 603 special registers */
  416.  
  417.     ULONG            DMISS;
  418.     ULONG            DCMP;
  419.     ULONG            HASH1;
  420.     ULONG            HASH2;
  421.     ULONG            IMISS;
  422.     ULONG            ICMP;
  423.     ULONG            RPA;
  424.  
  425.     /* 604e special registers */
  426.  
  427.     /* Version 0 ends here */
  428.  
  429.     ULONG            MSR;
  430.  
  431.     /* Version 1 ends here */
  432.  
  433.     /* Size depends on Version */
  434. };
  435.  
  436. /* Current supported Version
  437.  */
  438.  
  439. #define    EXCEPTIONMSG_VERSION    1
  440.  
  441. /*
  442.  * Current supported Types
  443.  */
  444.  
  445. /*
  446.  * These are the processor exceptions
  447.  */
  448.  
  449. #define    EXCEPTION_UNKNOWN        0    /* Won`t happen */
  450. #define    EXCEPTION_RESET            1    /* Won`t happen */
  451. #define    EXCEPTION_MACHINECHECK        2    /* Won`t happen */
  452. #define    EXCEPTION_DATAACCESS        3
  453. #define    EXCEPTION_INSTRUCTIONACCESS    4
  454. #define    EXCEPTION_EXTERNALINTERRUPT    5    /* Won`t happen */
  455. #define    EXCEPTION_ALIGNMENT        6
  456. #define    EXCEPTION_PROGRAM        7
  457. #define    EXCEPTION_FPUUNAVAILABLE    8
  458. #define    EXCEPTION_DECREMENTER        9
  459. #define    EXCEPTION_INTERFACEERROR    10
  460. #define    EXCEPTION_RESERVED_B        11
  461. #define    EXCEPTION_SYSTEMCALL        12
  462. #define    EXCEPTION_TRACE            13
  463. #define    EXCEPTION_FPUASSIST        14
  464. #define    EXCEPTION_RESERVED_F        15
  465. #define    EXCEPTION_IMISS            16
  466. #define    EXCEPTION_DLOADMISS        17
  467. #define    EXCEPTION_DSTOREMISS        18
  468. #define    EXCEPTION_IADDRESSBREAK        19
  469. #define    EXCEPTION_SYSTEMMANAGEMENTINT    20
  470.  
  471.  
  472. /*
  473.  * These are the kernel exceptions
  474.  * to signal certain events
  475.  */
  476.  
  477. #define    EXCEPTION_MSG            0x80000000
  478.  
  479. /*
  480.  * You receive this exception type
  481.  * when the Kernel could stop a Task
  482.  * successfully after a Stop or Trace
  483.  * operation.
  484.  * Look at PPCTASKTAG_STOPTASK for example
  485.  */
  486.  
  487. #define    EXCEPTION_STOPTASK        (EXCEPTION_MSG + 0x0)
  488.  
  489. /*
  490.  * You receive this exception type
  491.  * when the task completes.
  492.  * In this case the ONLY valid fields in the
  493.  * ExceptionMsg are the Version field and the
  494.  * the Message type.
  495.  */
  496.  
  497. #define    EXCEPTION_FINISHTASK        (EXCEPTION_MSG + 0x1)
  498.  
  499.  
  500. /**************************************************
  501.  *
  502.  *
  503.  *              PPCStartTask() Tags
  504.  *
  505.  *
  506.  **************************************************/
  507.  
  508. #define    PPCTASKSTARTTAG_DUMMY        (TAG_USER + 0x22000)
  509.  
  510. /* Just run a Task again
  511.  * ti_Data=BOOL
  512.  */
  513. #define    PPCTASKSTARTTAG_RUN        (PPCTASKSTARTTAG_DUMMY + 0x0)
  514.  
  515. /* Single Step the next instruction
  516.  * ti_Data=BOOL
  517.  */
  518. #define    PPCTASKSTARTTAG_TRACE        (PPCTASKSTARTTAG_DUMMY + 0x1)
  519.  
  520. /* Branch until a Trace instruction
  521.  * Processor dependent
  522.  * ti_Data=BOOL
  523.  * NOT SUPPORTED YET
  524.  */
  525. #define    PPCTASKSTARTTAG_BRANCHTRACE    (PPCTASKSTARTTAG_DUMMY + 0x2)
  526.  
  527. /* Run until Instruction hit
  528.  * the Breakpoint Address
  529.  * Processor dependent
  530.  * ti_Data=BOOL
  531.  * NOT SUPPORTED YET
  532.  */
  533. #define    PPCTASKSTARTTAG_IBREAK        (PPCTASKSTARTTAG_DUMMY + 0x3)
  534.  
  535. /* Run until DataAccess hit
  536.  * the Breakpoint Address
  537.  * Processor dependent
  538.  * ti_Data=BOOL
  539.  * NOT SUPPORTED YET
  540.  */
  541. #define    PPCTASKSTARTTAG_DBREAK        (PPCTASKSTARTTAG_DUMMY + 0x4)
  542.  
  543. #endif
  544.